package com.ny.dto;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.http.HttpStatus;

/**
 * 响应结果
 *
 * @author MSI-NB
 * @date 2025-03-08 13:14:38
 */
@Data
public class RestResult<T> {

    /**
     * 业务返回码
     */
    @ApiModelProperty(value = "业务返回码")
    private Integer code;

    /**
     * 业务提示信息
     */
    @ApiModelProperty(value = "业务提示信息")
    private String msg;

    /**
     * 业务数据
     */
    @ApiModelProperty(value = "业务数据")
    private T rows;

    public RestResult() {
    }

    public RestResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public RestResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.rows = data;
    }

    public static <T> RestResult<T> success(T data){
        RestResult<T> r = new RestResult<>();
        r.setCode(200);
        r.setMsg("Success");
        r.setRows(data);
        return r;
    }

}
